home *** CD-ROM | disk | FTP | other *** search
- Path: news.netins.net!trg1
- From: hhowe@trgnet.com (Harold Howe)
- Newsgroups: comp.lang.c++
- Subject: Question: passing ptr to private data
- Date: Wed, 14 Feb 96 14:45:45 GMT
- Organization: Technology Resource Group
- Message-ID: <4fsvte$igq@insosf1.netins.net>
- NNTP-Posting-Host: desm-20-13.dialup.netins.net
- X-Newsreader: News Xpress Version 1.0 Beta #3
-
- Greetings.
-
- I am currenlty writing a TurboVision application, but my question is about OO
- concepts and would also apply to owl programming.
-
- My application class contains a private structure with configuration
- information. I need to pass this structure to a dialog box class so the
- structure can be modified. Currently, I pass the address of the structure,
- which means the dialog class has direct access to the application classes
- private structure. My code resembles this:
-
- class TMyApp: public TApplication
- {
- private:
- ConfigStructure app_config;
- TMyDialog *dlg;
- public:
- void initDlg()
- {
- dlg = new TMyDialog(&app_config);
- }
- ...
- };
-
- class TMyDialog : public TDialog
- {
- public:
- TMyDialog(ConfigStructure *cfg);
- private:
- ConfigStucture *dlg_config;
- ...
- ... plus other functions that interact with dlg_config
- };
-
- TMyDialog::TMyDialog(ConfigStructure *cfg)
- {
- dlg_config = cfg;
- }
-
- Does this violate encapsulation? Any suggestions and criticisms would be
- appreciated.
-
- Harold Howe
- hhowe@trgnet.com
-